package com.nave.princesslife.baseboard.functionality;

import java.util.List;

import com.nave.princesslife.R;
import com.nave.princesslife.main.ItemsBought;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class Room_SkinsAdapter extends BaseAdapter {

	private Context context;
	private List<Skins_Base> skins;
	
	public Room_SkinsAdapter(Context context, List<Skins_Base> skins) {
		this.context = context;
		this.skins = skins;
	}

	@Override
	public int getCount() {
		return skins.size();
	}

	@Override
	public Object getItem(int position) {
		return skins.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		
		Skins_Base sb = skins.get(position);
		LayoutInflater inflater = (LayoutInflater) this.context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View v = inflater.inflate(R.layout.activity_room_skins, null);

		TextView skinName = (TextView) v.findViewById(R.id.room_skins_name);
		ImageView iv = (ImageView) v.findViewById(R.id.room_skins_image);

		skinName.setText(sb.getName());
		iv.setImageResource(sb.getImage());
		
		//Se for a pele atual, deixar o background verde.
		if (sb.getBitmap() == ItemsBought.getInstance().getCurrentSkin())
			v.setBackgroundColor(Color.rgb(72, 255, 0));
		
		return v;
	}

}
